﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = new HttpCookie("CurrentUser", Server.UrlEncode(TextBox1.Text));
            cookie.Expires = DateTime.Now.AddDays(2);
            Response.Cookies.Add(cookie);

            Response.Cookies["pwd"].Value = TextBox2.Text;
            Response.Cookies["pwd"].Expires = DateTime.Now.AddHours(2);
            Response.Redirect("WebForm2.aspx");
            //if (TextBox1.Text=="admin"&& TextBox2.Text=="123456")
            //{
            //    Literal1.Text = "登录成功！";
            //    Response.Redirect("WebForm2.aspx");
            //}
            //else
            //{
            //    Literal1.Text = "用户名或密码错误！";
            //}
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            this.TextBox1.Text = "";
            this.TextBox2.Text = "";
        }
    }
}